package com.qinggeng.project.system.controller;

import com.qinggeng.common.utils.poi.ExcelUtil;
import com.qinggeng.framework.aspectj.lang.annotation.Log;
import com.qinggeng.framework.aspectj.lang.enums.BusinessType;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.framework.web.page.TableDataInfo;
import com.qinggeng.project.system.domain.Resume;
import com.qinggeng.project.system.domain.SysAdver;
import com.qinggeng.project.system.service.IResumeService;
import com.qinggeng.project.system.service.ISysAdverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 招聘简历管理Controller
 *
 * @author qinggeng
 * @date 2020-02-12
 */
@RestController
@RequestMapping("/system/resume")
public class ResumeController extends BaseController
{
    @Autowired
    private IResumeService resumeService;

    /**
     * 查询招聘简历管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:resume:list')")
    @GetMapping("/list")
    public TableDataInfo list(Resume resume)
    {
        startPage();
        List<Resume> list = resumeService.listResume(resume);
        return getDataTable(list);
    }

    /**
     * 导出招聘简历管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:resume:export')")
    @Log(title = "招聘简历管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Resume resume)
    {
        List<Resume> list = resumeService.listResume(resume);
        ExcelUtil<Resume> util = new ExcelUtil<Resume>(Resume.class);
        return util.exportExcel(list, "resume");
    }

    /**
     * 获取招聘简历管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:resume:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(resumeService.getResumeById(id));
    }

    /**
     * 新增招聘简历管理
     */
    @PreAuthorize("@ss.hasPermi('system:resume:add')")
    @Log(title = "招聘简历管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Resume resume)
    {
        resumeService.insertResume(resume);
        return AjaxResult.success();
    }

   /* *
     * 修改招聘简历管理*/

    @PreAuthorize("@ss.hasPermi('system:resume:edit')")
    @Log(title = "招聘简历管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Resume resume)
    {
        return toAjax(resumeService.checkResume(resume));
    }

   /* *
     * 删除招聘简历管理*/

    @PreAuthorize("@ss.hasPermi('system:resume:remove')")
    @Log(title = "招聘简历管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(resumeService.deleteResumeByIds(ids));
    }
}
